<template>
  <div id="cart-list">
    <div v-if="list.length >= 0" class="cart">
      <cart-list-item
        v-for="item in list"
        :itemInfo="item"
        :key="item.iid"
        class="list"
      />
    </div>
    <div class="tips">
      {{ tips }}
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import CartListItem from "@/views/cart/childComps/CartListItem";
export default {
  name: "CartList",
  components: {
    CartListItem,
  },
  computed: {
    ...mapGetters({
      list: "cartList",
    }),
    tips() {
      return this.list.length === 0
        ? "购物车为空"
        : "共" + this.list.length + "件商品";
    },
  },
};
</script>

<style scoped>
#cart-list {
  margin-top: 44px;
  padding-top: 5px;
  width: 100%;
  margin-bottom: 65px;
}
.tips {
  padding-top: 10px;
  text-align: center;
}
</style>
